package com.baidu.mobstat;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Handler;
import android.os.HandlerThread;
import com.baidu.mobstat.a.b;
import java.util.Date;
import java.util.Timer;

class g
{
  private static HandlerThread a = new HandlerThread("LogSenderThread");
  private static Handler h;
  private static g i = new g();
  private boolean b = false;
  private SendStrategyEnum c = SendStrategyEnum.APP_START;
  private int d = 1;
  private Timer e;
  private int f = 0;
  private boolean g = false;

  private g()
  {
    a.start();
    h = new Handler(a.getLooper());
  }

  public static g a()
  {
    return i;
  }

  public SharedPreferences a(Context paramContext)
  {
    return paramContext.getSharedPreferences("__Baidu_Stat_SDK_SendRem", 0);
  }

  public void a(int paramInt)
  {
    if ((paramInt < 0) || (paramInt > 30))
      return;
    this.f = paramInt;
  }

  public void a(Context paramContext, SendStrategyEnum paramSendStrategyEnum, int paramInt, boolean paramBoolean)
  {
    SharedPreferences.Editor localEditor = a(paramContext).edit();
    if (paramSendStrategyEnum.equals(SendStrategyEnum.SET_TIME_INTERVAL))
      if ((paramInt > 0) && (paramInt <= 24))
      {
        this.d = paramInt;
        this.c = SendStrategyEnum.SET_TIME_INTERVAL;
        localEditor.putInt("sendLogtype", this.c.ordinal());
        localEditor.putInt("timeinterval", this.d);
      }
    while (true)
    {
      this.b = paramBoolean;
      localEditor.putBoolean("onlywifi", this.b);
      b.a("Mobads SDK", "sstype is:" + this.c.name() + " And time_interval is:" + this.d + " And m_only_wifi:" + this.b);
      localEditor.commit();
      return;
      b.b(new Object[] { "setSendLogStrategy", "time_interval is invalid, new strategy does not work" });
      continue;
      this.c = paramSendStrategyEnum;
      localEditor.putInt("sendLogtype", this.c.ordinal());
      if (!paramSendStrategyEnum.equals(SendStrategyEnum.ONCE_A_DAY))
        continue;
      localEditor.putInt("timeinterval", 24);
    }
  }

  public void a(boolean paramBoolean, Context paramContext)
  {
    this.g = paramBoolean;
    SharedPreferences.Editor localEditor = a(paramContext).edit();
    localEditor.putBoolean("exceptionanalysisflag", this.g);
    b.a("Mobads SDK", "APP_ANALYSIS_EXCEPTION is:" + this.g);
    localEditor.commit();
  }

  public void b(Context paramContext)
  {
    Object localObject1 = SendStrategyEnum.APP_START;
    SharedPreferences.Editor localEditor = a(paramContext).edit();
    String str4;
    try
    {
      str4 = q.a(paramContext, "BaiduMobAd_EXCEPTION_LOG");
      if (!str4.equals(""))
      {
        if (!str4.equals("true"))
          break label218;
        e.a().a(paramContext);
        label172: label60: label218: label363: label111: label252: localEditor.putBoolean("exceptionanalysisflag", true);
      }
    }
    catch (Exception localException3)
    {
      String str3;
      try
      {
        str3 = q.a(paramContext, "BaiduMobAd_SEND_STRATEGY");
        if (!str3.equals(""))
        {
          if (!str3.equals(SendStrategyEnum.APP_START.name()))
            break label252;
          localObject1 = SendStrategyEnum.APP_START;
          localEditor.putInt("sendLogtype", SendStrategyEnum.APP_START.ordinal());
        }
      }
      catch (Exception localException3)
      {
        try
        {
          String str2 = q.a(paramContext, "BaiduMobAd_TIME_INTERVAL");
          if (!str2.equals(""))
          {
            int j = Integer.parseInt(str2);
            if ((((SendStrategyEnum)localObject1).ordinal() == SendStrategyEnum.SET_TIME_INTERVAL.ordinal()) && (j > 0) && (j <= 24))
              localEditor.putInt("timeinterval", j);
          }
        }
        catch (Exception localException3)
        {
          try
          {
            String str1 = q.a(paramContext, "BaiduMobAd_ONLY_WIFI");
            if (!str1.equals(""))
            {
              if (!str1.equals("true"))
                break label363;
              localEditor.putBoolean("onlywifi", true);
            }
            do
            {
              localEditor.commit();
              return;
              if (str4.equals("false"));
              localEditor.putBoolean("exceptionanalysisflag", false);
              break label60:
              localException1 = localException1;
              b.a(localException1);
              break label60:
              if (str3.equals(SendStrategyEnum.ONCE_A_DAY.name()))
              {
                localObject1 = SendStrategyEnum.ONCE_A_DAY;
                localEditor.putInt("sendLogtype", SendStrategyEnum.ONCE_A_DAY.ordinal());
                localEditor.putInt("timeinterval", 24);
                break label111:
                localException2 = localException2;
                Object localObject2 = localObject1;
                b.a(localException2);
                localObject1 = localObject2;
              }
              if (str3.equals(SendStrategyEnum.SET_TIME_INTERVAL.name()));
              localObject1 = SendStrategyEnum.SET_TIME_INTERVAL;
              localEditor.putInt("sendLogtype", SendStrategyEnum.SET_TIME_INTERVAL.ordinal());
              break label111:
              localException3 = localException3;
              b.a(localException3);
              break label172:
            }
            while (!str1.equals("false"));
            localEditor.putBoolean("onlywifi", false);
          }
          catch (Exception localException4)
          {
            b.a(localException4);
          }
        }
      }
    }
  }

  public void c(Context paramContext)
  {
    h.post(new h(this, paramContext));
  }

  public void d(Context paramContext)
  {
    a(paramContext).edit().putLong("lastsendtime", new Date().getTime()).commit();
  }

  public void e(Context paramContext)
  {
    this.e = new Timer();
    this.e.schedule(new j(this, paramContext), 3600000 * this.d, 3600000 * this.d);
  }
}

/* Location:           C:\Users\god\Desktop\liunianjishiben_V1.1_mumayi_3745b_dex2jar.jar
 * Qualified Name:     com.baidu.mobstat.g
 * JD-Core Version:    0.5.4
 */